package com.ceba.test.base.web.response;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "responseInfo")
public class WebServiceResponseInfo implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int successNum;
	
	/**
	 * code =100 异常情况
	 */
	private int code;

	@SuppressWarnings("rawtypes")
	private List successPath;
	
	private String message;
	
	private int signNum;
	
	private Map<String,String> errFiles = new HashMap<String,String>();
	
	@SuppressWarnings("rawtypes")
	private List failPath;

	/**
	 * key: fileName
	 * value: QrId
	 */
	private List<String> qrIdList = new ArrayList<String>();

	private String exportExcel;

	public void init() {
		this.message = "";
		this.code = 0;
		this.signNum = 0;
		this.successNum = 0;
	}

	public void merge(WebServiceResponseInfo rightVal) {
		this.successNum += rightVal.getSuccessNum();
		this.signNum += rightVal.getSignNum();

		StringBuffer err = new StringBuffer();
		err.append(this.message);
		err.append(rightVal.getMessage());
		this.message = err.toString();

		if (rightVal.getCode() != 0) {
			this.code = rightVal.getCode();
		}

		if (this.successPath == null) {
			this.successPath = new ArrayList<String>();
		}
		if (rightVal.getSuccessPath() != null) {
			this.successPath.addAll(rightVal.getSuccessPath());
		}

		if (this.errFiles == null) {
			this.errFiles = new HashMap<String, String>();
		}
		if (rightVal.getErrFiles() != null) {
			this.errFiles.putAll(rightVal.getErrFiles());
		}

		if (this.qrIdList == null) {
			this.qrIdList = new ArrayList<String>();
		}
		if(rightVal.getQrIdList() != null) {
			this.qrIdList.addAll(rightVal.getQrIdList());
		}
	}

	public List<String> getQrIdList() {
		return qrIdList;
	}

	public void setQrIdList(List<String> qrIdList) {
		this.qrIdList = qrIdList;
	}

	public String getMessage() {
		return message;
	}

	@SuppressWarnings("rawtypes")
	public List getFailPath() {
		return failPath;
	}

	@SuppressWarnings("rawtypes")
	public void setFailPath(List failPath) {
		this.failPath = failPath;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@SuppressWarnings("rawtypes")
	public List getSuccessPath() {
		return successPath;
	}

	@SuppressWarnings("rawtypes")
	public void setSuccessPath(List successPath) {
		this.successPath = successPath;
	}

	public int getSuccessNum() {
		return successNum;
	}

	public void setSuccessNum(int successNum) {
		this.successNum = successNum;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	@SuppressWarnings("rawtypes")
	public Map getErrFiles() {
		return errFiles;
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void setErrFiles(Map errFiles) {
		this.errFiles = errFiles;
	}
	
	public int getSignNum() {
		return signNum;
	}

	public void setSignNum(int signNum) {
		this.signNum = signNum;
	}

	public String getExportExcel() {
		return exportExcel;
	}

	public void setExportExcel(String exportExcel) {
		this.exportExcel = exportExcel;
	}

	@Override
	public String toString(){
		return "{successNum:"+successNum+",signNum:"+signNum+",code:"+code+",message:"+message+",successPath:"+successPath+"}";
		
	}
}
